//
//  JXHEmoticonCell.swift
//  emojeTest
//
//  Created by juxiaohui on 16/11/2.
//  Copyright © 2016年 juxiaohui. All rights reserved.
//

import UIKit

class JXHEmoticonCell: UICollectionViewCell {

    var emoticon : JXHEmoticon? {
        didSet{
            guard let emoticon = emoticon else {
                return
            }
           emoticonBtn.setImage(UIImage.init(contentsOfFile: emoticon.pngPath ?? ""), for: .normal)
            emoticonBtn.setTitle(emoticon.emojiCode, for: .normal)
            
            if emoticon.isRemove {
                emoticonBtn.setImage(UIImage.init(named: "compose_emotion_delete"), for: .normal)
                emoticonBtn.setImage(UIImage.init(named: "compose_emotion_delete_highlighted"), for: .highlighted)
            }
        }
    }
    
    lazy var emoticonBtn = UIButton()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        contentView.addSubview(emoticonBtn)

        emoticonBtn.snp.makeConstraints { (make) in
            make.edges.equalTo(UIEdgeInsets.init())
        }
        
        emoticonBtn.isUserInteractionEnabled = false
        
        emoticonBtn.titleLabel?.font = UIFont.systemFont(ofSize: 32)
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
